package com.xo.common.until;

import com.github.pagehelper.PageInfo;
import com.xo.common.Result.CommonPage;

import java.util.List;

public class PageUtil {


    /**
     * 将PageHelper分页后的list转为分页信息
     */
    public static <T> CommonPage<T> getPageList(List<T> list) {
        CommonPage<T> result = new CommonPage<>();
        PageInfo<T> pageInfo = new PageInfo<>(list);
        result.setTotalPage(pageInfo.getPages());
        result.setPageNum(pageInfo.getPageNum());
        result.setPageSize(pageInfo.getPageSize());
        result.setTotal(pageInfo.getTotal());
        result.setList(pageInfo.getList());
        return result;
    }

}
